<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
	<head>
		<title>个人信息</title>
		<%@include file="/WEB-INF/base.jspf"%>
		<style type="text/css">
			*{font-size: 14px;}
			/* li{height: 60px;line-height: 60px;border-top: 1px solid #f2f2f2;} */
			th,td{text-align: center;}
			tr{background: white;height: 30px;}
			table *{font-size: 14px;}
			.indexTD, .buyTD {
			color:blue!important;
			cursor: pointer;}
			.div-c-detailInfo, .div-c-buyContentDiv {
				position: absolute;
				top:0;
				left:0;
				right:0;
				bottom:0;
				background-color: rgba(0, 0, 0, 0.6);
				display:none;
				padding:100px 30px;
				color:white;
			}
			.detailInfo-in {
				display: block;
			}
			.div-c-buyContentDiv-block {
			display:flex;
			align-items: center;
			justify-content:center;}
			.div-c-detailInfo > ul {
			margin-bottom: 0;
			background-color:white;
			color:black;
			padding:10px;
			position: relative;
			}
			.div-c-detailInfo > ul > .span-c-closeDetailDiv {
				position: absolute;
				top:0px;
				right:0px;
				padding-right:10px;
				font-size:24px;
				color: black;
			}
			.li-c-wanfaInfo {
			padding-left: 17px;
			word-break: break-all;
			}
			.div-c-buyContentDiv > .buy-inner {
				display:block;
				text-align: center;
			}
			
			.div-c-buyContentDiv > .buy-inner > input {
			margin-top:16px;
			margin-bottom:16px;
			color:black;}
			.div-c-buyContentDiv > .buy-inner > button {
			margin-top:0;}
			.div-c-buyContentDiv > .buy-inner > button + button {
			margin-left:16px;}
			tbody th, tbody td {
				white-space:nowrap;
				padding:10px 0;
			}
			#span-i-myHeMai, #span-i-historyGenDan {
				font-size:14px;
				font-weight:bold;
			}
			.sub-ul-wanfa {
				display:none;
			}
			.sub-ul-wanfa-active {
				display:block;
			}
			.modal-footer {
				padding: 6px;
    			text-align: center;
			}
			#span-i-gendanWanfa, #span-i-myHeMai, #span-i-historyGenDan {
				cursor: pointer;
			}
			.moneyText {
				color:red;
			}
			.modal-footer > button {
				width:80%;
			}
 			.myHeMaiItem {
				border-radius: 10px;
				border-top:5px solid red;
			    border: 1px solid silver;
			    box-shadow: 2px 3px 1px silver;
			    padding: 10px;
			    margin-bottom: 20px;
			    text-align: left;		
			    position: relative;	
			}
			.myHeMaiItem > span {
				position: absolute;
				top:-10px;
				left:10px;
				background-color:white;
				font-weight:bold;
			}
			.myHeMaiItem li {
				margin-bottom:5px;
			}
			.myHeMaiItem button {
				margin-top:0;
				width:46%;
			}
			.myHeMaiItem #li-i-btnDetail {
				text-align: center;
				margin-bottom:0;
			}
			.myHeMaiItem li:first-child {
				
			}
			.modal { overflow: auto !important; }
			.cancelScroll {
				overflow: hidden!important;
			}
			.fixed {
				position: fixed;
			}
			.table-c-allGenDan td, .table-c-allGenDan th {
				white-space: nowrap;
				border-collapse: collapse;
			}
			.span-c-beizhuItem {
				display:inline-block;
				padding:6px;
				border:1px solid #d6d6d6;
				width:25%;
				margin-right:4px;
				margin-bottom:4px;
				text-align: center;
				border-radius: 4px;
				cursor: pointer;
			}
			td.td-table-shenglv {
				color:red;
			}
		    .icon {
		       width: 1em; height: 1em;
		       vertical-align: -0.15em;
		       fill: currentColor;
		       overflow: hidden;
		    }
			.beizhuItemActive {
				color:white;
				background:#059BF3;
				border-color:#059BF3;
			}
			.sub-ul-wanfa.active {
				display:block;
			}
			.col-sm-4, .col-xs-12 {
				padding:0;
			}
			td.td-gendan-gendan, td.td-gendan-detail {
				cursor: pointer;
			}
			.hidden-td {
				display:none;
			}
			.ul-c-detailOrder td {
				white-space: normal;
			}
		</style>
		<script type="text/javascript" src="/js/font_612184_suc1kkwgeaa1c3di.js"></script>
	</head>

	<body style="background: #F1F1F1 ;">
		<div class=""> 
			<div id="header" class="col-xs-12 col-sm-4 col-sm-offset-4" style="position: fixed;top: 0px;left: 0px;z-index: 100;">
				<div class="bg-theme" style="display:flex;justify-content:space-between;position:relative;">
					<div style="display:flex;flex-direction:column;align-items:center;margin-left:10px;">
						<div id="span-i-myHeMai" style="padding:5px 0;display:flex;align-items:center;margin-left:0;">我的跟单</div>
						<div id="span-i-historyGenDan" style="padding:5px 0;display:flex;align-items:center;">历史跟单</div>
					</div>
					<strong style="font-size: 20px;padding:11px 0;display:inline-flex;align-items:center;">跟单中心</strong>
					<div id="span-i-gendanWanfa" style="font-size:14px;font-weight:bold;margin-right:10px;padding:10px 0;display:flex;align-items:center;">玩法说明</div>
				</div>
			</div>
			<div class="div-c-mainContent col-xs-12 col-sm-4 col-sm-offset-4" style="overflow:auto;-webkit-overflow-scrolling : touch;">
				<table class="table-c-allGenDan table table-striped table-bordered table-hover" style="margin-bottom:0;">
					<thead>
						<tr>
							<th style="display:none;"></th>
							<th style="display:none;"></th>
							<th style="display:none;"></th>
							<th style="display:none;"></th>
							<th style="display:none;"></th>
							<th style="display:none;"></th>
							<th style="display:none;"></th>
							<th>序号</th>
							<th>发起人</th>
							<th>胜率</th>
							<th>状态</th>
							<th>跟单</th>
							<th>详情</th>
						</tr>
					</thead>
					<tbody id="tbody-all-gendan">
					</tbody>
				</table>	
			</div>
		<div class="col-xs-12 col-sm-4 col-sm-offset-4 text-center foot">
			<iframe src="f.jsp"></iframe>
		</div>
		</div>

<!-- 模态框（Modal） -->
<div class="modal fade" id="detail-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="max-height:60vh;">
        <div class="modal-content" style="height:100%;">
            <div class="modal-header">
                <h4 class="modal-title" id="" style="text-align: center;">★跟单详情★</h4>
            </div>
            <div class="modal-body" style="overflow:auto;max-height:60vh;">
            	<table class="table table-striped table-bordered table-hover" style="overflow: auto;">
            		<tbody class="ul-c-detailOrder">
            			
            		</tbody>
            	</table>
<!--             	<ul class="ul-c-detailOrder">
            		<li></li>
            		<li></li>
            		<li></li>
            		<li></li>
            		<li></li>
            		<li></li>
            	</ul> -->
            </div>
            <div class="modal-footer" style="">
                <button type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>


<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	    <div class="modal-dialog" style="margin: 2vh auto;">
	        <div class="modal-content">
	            <div class="modal-header">
	                <h4 class="modal-title" id="myModalLabel" style="text-align: center;letter-spacing:3px;">★我的跟单★</h4>
	            </div>
	            <div class="modal-body" id="div-i-myHeMaiBody" style="height:55vh;overflow: auto;">
					<div class="div-c-collapseItem active">
						<div class="div-c-collapseTitle">
							<svg class="icon" aria-hidden="true">
							    <use xlink:href="#icon-right"></use>
							</svg><span>我的跟单状况</span>
						</div>
					<div class="div-c-collapseContentWrapper" id="div-i-gendanZhuangkuang">
					</div>
					</div>
					<div class="div-c-collapseItem">
						<div class="div-c-collapseTitle">
							<svg class="icon" aria-hidden="true">
							    <use xlink:href="#icon-right"></use>
							</svg><span>我发起的跟单<span class='span-c-tiaoshu'></span>条</span>
						</div>
						<div class="div-c-collapseContentWrapper" id="div-i-MyFaQiGenDan">
						</div>
					</div>
					<div class="div-c-collapseItem">
						<div class="div-c-collapseTitle">
							<svg class="icon" aria-hidden="true">
							    <use xlink:href="#icon-right"></use>
							</svg><span>我参与的跟单<span class='span-c-tiaoshu'></span>条</span>
						</div>
						<div class="div-c-collapseContentWrapper"  id="div-i-MyCanYuGenDan">
						</div>
					</div>					
				</div>
	            <div class="modal-footer">
	                <button type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>
	            </div>
	        </div>
	    </div>
	</div>	
		<div class="modal-div-fakeModal" id="div-i-chooseBeiShuModal">
			<div class="div-c-modalContent">
				<h3 class="fakemodal-title">请填写跟单投注金额</h3>
				<div class="fakemodal-content">
					<span style="font-size:20px;display:inline-flex;align-items:center;"><input type="number" class="form-control gendan-touzhu-money" style="font-size:20px;margin-right:6px;">元</span>			
				</div>
				<div class="fakemodal-btnsGroup">
					<button class="btn btn-success" id="button-i-confirmGenDan">确认跟单</button>
					<button class="btn btn-default btn-class-closeFakeModal">关闭</button>
				</div>
			</div>
		</div>
			
		<div class="modal-div-fakeModal" id="div-i-noticeGenDan">
			<div class="div-c-modalContent">
				<h3 class="fakemodal-title"></h3>
				<div class="fakemodal-content"></div>
				<div class="fakemodal-btnsGroup"><button class="btn btn-default btn-class-closeFakeModal">关闭</button></div>
			</div>
		</div>		
	</body>
	<script type="text/javascript">
	//
	bindCollapseItemEvent()
	var PAY_AJAX_ITEM = {
		id:"",
		rebate:"",
		payMoney:"",
		gid: "",
		lotterCount: "",
	}
	$("#span-i-historyGenDan").on(getEndClickEvent(), function(e) {
		window.location.href = "/lishiGendan.do"
	})
	var initMainContent = function() {
		var headerHeight = $("#header")[0].clientHeight
		$(".div-c-mainContent").css("margin-top", headerHeight + "px")
		$(".div-c-mainContent").css("margin-bottom", "50px")
		$(".div-c-mainContent").css("height", (document.documentElement.clientHeight - headerHeight - 50) + "px")		
		$(".table-c-allGenDan").DataTable({
		      "bLengthChange": true,      
		      "bSort": false,
		      "bAutoWidth": false,
		      "dom": 't<"toolbar" pi>',
		      'aLengthMenu':[10],
		       "searching": true,  
		      "stateSave": true,
		      "stateDuration": 365,
		         "columns": [
							 { "data": "lotterCount", "className": "lotterCount-td hidden-td" },
		                     { "data": "orderid", "className": "orderid-td hidden-td" },
		                     { "data": "paymoney", "className": "paymoney-td hidden-td" },
		                     { "data": "rebate", "className": "rebate-td hidden-td" },
		                     { "data": "userid", "className": "userid-td hidden-td" },
		                     { "data": "id", "className": "id-td hidden-td" },
		                     { "data": "xuhao", "className": "xuhao-td" },
		                     { "data": "faqiren", "className": "faqiren-td" },
		                     { "data": "shenglv", "className": "td-table-shenglv" },
		                     { "data": "status", "className": "status-td" },
		                     { "data": "gendan", "className": "td-gendan-gendan td-gendan-control" },
		                     { "data": "xiangqing", "className": "td-gendan-detail td-gendan-control" },
		                 ],	
		      "ajax": {
	    	  	  "type": 'POST',
	    	      "url":"/gendan.do", 
	    	      "dataSrc": function(json) {
	    	    	  var newData = json
		  				if (newData.data.length == 0 || (newData.data.length == 1 && newData.data[0] == null)) {
		  					showNoResultNoticeModal("#div-i-noticeGenDan", "提示", "目前还没有用户发起跟单", "点击前往，立刻下注！", getXiaZhuUrl())
		  					return []
		  				}
		  				newData.data.sort(function(a, b) {
		  					return b.shenglv - a.shenglv 
		  				})
		  				var newDataArr = []
		  				for (var i = 0; i < newData.data.length; i++) {
		  					var item = newData.data[i]
		  					if (item == null) {
		  						return
		  					}
		  					var xuhao = i + 1
		  					var faqiren = item.huiyuanzh
		  					var shenglv = (Number(item.shenglv) * 100).toFixed(2)
		  					var newObj = {
		  						lotterCount: item.lotterCount,
		  						orderid: item.orderid,
		  						paymoney: item.payMoney,
		  						rebate: item.rebate,
		  						userid: item.userid,
		  						id: item.id,
		  						xuhao: xuhao,
		  						faqiren: faqiren,
		  						shenglv: String(shenglv) + "%",
		  						status: "认购中",
		  						gendan: "跟单",
		  						xiangqing: "详情",
		  					}
		  					newDataArr.push(newObj)
		  					//var html = "<tr data-orderid='" + item.orderid + "' data-paymoney='" + item.payMoney + "' data-rebate='" + item.rebate + "' data-userid='" + item.userid + "' data-id='" + item.id + "'><td>" + xuhao + "</td><td>" + faqiren + "</td><td class='td-table-shenglv'>" + shenglv + "%</td><td>认购中</td><td class='td-gendan-gendan td-gendan-control'>跟单</td><td class='td-gendan-detail td-gendan-control'>详情</td></tr>"
		  				}
		  				return newDataArr
	    	      }
		      },	
//		    "searching": true,l
		       "language": {//语言设置  
		            "zeroRecords": "暂无进行中的跟单",     
		            "sInfo": "第 _PAGE_ / _PAGES_ 页",     
		            "info": "没有数据",     
		            "oPaginate": {     
		                "sFirst": "首页",     
		                "sPrevious": "上一页",     
		                "sNext": "下一页",     
		                "sLast": "尾页"    
		          	},
		            "search":"",
		            "searchPlaceholder": "请输入关键字",
		            "infoFiltered":   "",
		            "infoEmpty":      "",
		         }
		    })
	}	
	
	
	
	var bindTableBtnEvent = function() {
		$(".table-c-allGenDan").on(getEndClickEvent(), "td.td-gendan-detail", function(event) {
			//<li style='font-weight:bold;'><i class='fa fa-star'></i> 期号 : " + qihaoValue + "</li>"
			var $parentTr = $(event.target).closest("tr")
			var idValue = $parentTr.find(".id-td").text()
			var payMoneyValue = $parentTr.find(".paymoney-td").text()
			var newRequest = {
				url: "/oneData.do",
				type: "post",
				data: {
					id:idValue
				},
				success: function(data) {
					var nData = JSON.parse(data)
					var newData = nData.data[0]
					$(".ul-c-detailOrder").html("")
					$(".ul-c-detailOrder").append("<tr><td style='font-weight:bold;'>彩种</td><td>" + newData.cname1 + "</td></tr>")
					$(".ul-c-detailOrder").append("<tr><td style='font-weight:bold;'>参与人数</td><td><span style='color:red;'>" + newData.counts + "</span>人</td></tr>")
					$(".ul-c-detailOrder").append("<tr><td style='font-weight:bold;'>佣金百分比</td><td style='color:red;'>" + String(newData.rebate * 100) + "%</td></tr>")
					$(".ul-c-detailOrder").append("<tr><td style='font-weight:bold;'>期号</td><td>" + newData.qihao + "</td></tr>")
					$(".ul-c-detailOrder").append("<tr><td style='font-weight:bold;'>发起时间</td><td>" + newData.createTime + "</td></tr>")
					$(".ul-c-detailOrder").append("<tr><td style='font-weight:bold;'>投注金额</td><td><span style='color:red;'>" + payMoneyValue + "</span>元</td></tr>")
					for (var i = 1; i < 41; i++) {
						var item = newData["cplay" + i]
						if (item != null) {
							$(".ul-c-detailOrder").append("<tr><td style='font-weight:bold;'>" + item + "</td><td>" + newData["str" + i] + "</td></tr>")
						}
					}
					$("#detail-modal").modal("show")
				},
				error: function(status) {
					showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "网络异常，请稍后重试")
				}
			}
			ajax(newRequest)	 		
			//
		})
		$(".table-c-allGenDan").on(getEndClickEvent(), "td.td-gendan-gendan", function(event) {
			if ("${user.state}" === "2") {
				showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "试玩账号无法参与跟单玩法，请注册正式账号")
				return
			}
			var $parentTr = $(event.target).closest("tr")
			if ($parentTr.find(".userid-td").text() === "${user.id}") {
				showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "无法购买自己发起的跟单")
				return				
			}
			var idValue = $parentTr.find(".id-td").text()
			var payMoneyValue = $parentTr.find(".paymoney-td").text()
			PAY_AJAX_ITEM.id = $parentTr.find(".orderid-td").text()
			PAY_AJAX_ITEM.rebate = $parentTr.find(".rebate-td").text()
			PAY_AJAX_ITEM.gid = idValue
			PAY_AJAX_ITEM.payMoney = payMoneyValue	
			PAY_AJAX_ITEM.lotterCount = $parentTr.find(".lotterCount-td").text() 
			showFakeModal("#div-i-chooseBeiShuModal")
		})		
	}
	//tbody-all-gendan
	
/* 	var initBeiShuEvent = function() {
		var newRequest = {
			url: getBase()+"/payCount.do",
			type: "post",
			data: {
			},
			success: function(data) {
				var newData = JSON.parse(data)
				var beishuArray = newData.data.split(",")
				for (var i = 0; i < beishuArray.length; i++) {
					var item = beishuArray[i]
					var html = "<span class='span-c-beizhuItem' data-value='" + item + "'>" + item + "倍</span>"
					$("#div-i-beishuWrapper").append(html)
				}
				$("#div-i-beishuWrapper").find(".span-c-beizhuItem")[0].classList.add("beizhuItemActive")
			},
			error: function(status) {
				showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "网络异常，请稍后重试")
			}
		}
		ajax(newRequest)	
		$("#div-i-beishuWrapper").on(getEndClickEvent(), ".span-c-beizhuItem", function(event) {
			$(".beizhuItemActive").removeClass("beizhuItemActive")
			$(event.target).addClass("beizhuItemActive")
		})
	} */
	
	initMainContent()
	bindTableBtnEvent()
	//initBeiShuEvent()
	//
	var doubleNumberReg = /^[0-9]+([.]{1}[0-9]{1,2})?$/
	$("#button-i-confirmGenDan").on(getEndClickEvent(), function(event) {
		//
		if (!doubleNumberReg.test($(".gendan-touzhu-money").val()) || Number($(".gendan-touzhu-money").val()) <= 1) {
			showNormalNoticeModal("#div-i-noticeGenDan", "提示", "单注金额至少为1元")	
			return			
		}
		var beishuValue = $(".beizhuItemActive").attr("data-value")
		//var allMoney = Number(PAY_AJAX_ITEM.payMoney) * Number(beishuValue)
		//allMoney = Math.round(allMoney * 100) / 100
		var allMoney = $(".gendan-touzhu-money").val()
		var newRequest = {
			url: '//cp/order/payGendan.do',
			type: "post",
			data: {
				id: PAY_AJAX_ITEM.id,
				state: "1",
				testState: "1",
				rebate: PAY_AJAX_ITEM.rebate,
				payMoney: allMoney,
				gid: PAY_AJAX_ITEM.gid,
				moneys: PAY_AJAX_ITEM.payMoney,
				counts: 1,
				//beishu: beishuValue,
			},
			success: function(data) {
				var joinGenDan = JSON.parse(data)
				if (joinGenDan.data == "3") {
					showNormalNoticeModal("#div-i-noticeGenDan", "提示", "余额不足，无法进行跟单操作！")	
					return
				}
				if (joinGenDan.data == 10) {
					showNormalNoticeModal("#div-i-noticeGenDan", "提示", joinGenDan.message)	
					return					
				}
				if (joinGenDan.data == "0") {
					showNormalNoticeModal("#div-i-noticeGenDan", "提示", "系统繁忙，请稍后再试")	
					return
				}
				if (joinGenDan.data == "1") {
					showNormalNoticeModal("#div-i-noticeGenDan", "提示", "跟单成功！")					
					$("#div-i-chooseBeiShuModal .btn-class-closeFakeModal").trigger("touchstart")
				}
			},
			error: function(status) {
				showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "网络异常，请稍后重试")
			}
		}
		ajax(newRequest)			
	})
	
	var kaijiang_Obj = {
		"1": "待开奖",
		"2": "未中奖",
		"3": "已中奖",
	}
	
	var hansType2English = {
		"参与": "canyu",
		"发起": "faqi"
	}
	
	var createMyGenDanItem = function(dataItem, type) {
		var typeValue = ""
		var buyMoney = ""
		var fanganJine = ""
		var beishuValue = ""
		var kaijiangHaoMa = ""
		var zhongjiangMoney = ""
		var fanganMoney = ""
		var checkText = "查看详情"
		// acount         // 发起的时候是不用的，参与的   方案金额
		// paymoney       // 发起的时候是方案金额，参与的时候是购买金额
		if (dataItem.state != "1") {
			kaijiangHaoMa = "<li>中奖号码：<span class='moneyText' style='font-weight:bold;'>" + dataItem.checkNum + "</span></li>"
			/* checkText = "查看详情" */
		}
		if (dataItem.state == "3") {
			fanganMoney = "<li>方案中奖金额：<span class='moneyText' style='font-weight:bold;'>" + dataItem.goalmoney + "元</span></li>"
		}	
		if (dataItem.state == "3") {
			zhongjiangMoney = "<li>收入金额：<span class='moneyText' style='font-weight:bold;'>" + dataItem.shouru + "元</span></li>"
		}
		if (type == "发起") {
			typeValue = "我是发起人"
			fanganJine = "<li>方案金额：<span class='moneyText' style='font-weight:bold;'>" + dataItem.payMoney + "元</span></li>"
		} else {
			typeValue = "我是参与者"
			buyMoney = "<li>购买金额：<span class='moneyText' style='font-weight:bold;'>" + dataItem.payMoney + "元</span></li>"
			fanganJine = "<li>方案金额：<span class='moneyText' style='font-weight:bold;'>" + dataItem.acount + "元</span></li>"
		}
		var allWanFa = "<li style='font-weight:bold;margin-top:6px;'>投注玩法：</li>"
		for (var j = 1 ; j < 41; j++) {
			var objItem = dataItem["cplay" + j]
			if (objItem != null) {
				allWanFa += "<li>" + objItem + "：" + dataItem["str" + j] + "</li>"
			}
		}
		var newFaQiItem = "<ul class='ul-c-gendan-" + hansType2English[type] + " myHeMaiItem'><span style='' class='span-type-hemaiPerson'>" + typeValue + "</span><li><span>彩种名称：" + dataItem.cname1 + "</span></li><li><span>期号：" + dataItem.qihao + "</span></li><li><span>创建时间：" + dataItem.createTime + "</span></li><li><span>发起人：" + dataItem.huiyuanzh + "</span></li><li><span>方案编号：" + dataItem.orderNum + "</span></li>" + fanganJine + beishuValue + buyMoney + "<li>开奖状态:<span style='color:red;font-weight:bold;'>" + kaijiang_Obj[dataItem.state] + "</span></li><li id='li-i-btnDetail'><button class='btn-viewDetailGenDanItem btn btn-success'>" + checkText + "</button></li><ul class='sub-ul-wanfa'>" + fanganMoney + zhongjiangMoney + kaijiangHaoMa + allWanFa + "</ul></ul>"		
		return newFaQiItem
	}
	
	var insertGenDanItem = function(data, $node, type) {
		var newData = JSON.parse(data)
		$($node).html("")
		var $titleSpan = $($node).prev().find(".span-c-tiaoshu")
		for (var i = 0; i < newData.data.length; i++) {
			var dataItem = newData.data[i]
			if (!dataItem) {continue}
			var newFaQiItem = createMyGenDanItem(dataItem, type)
			$($node).append(newFaQiItem)
		}
		if ($($node + " .myHeMaiItem").length == 0) {
			$($node).append("暂无" + type + "的跟单")
		}		
		$titleSpan.text($($node)[0].children.length)
	}
	
	$("#span-i-myHeMai").on(getEndClickEvent(), function(event) {
		var newRequest = {
			url: "/shop.do",
			type: "post",
			data: {
			},
			success: function(data) {
				var newData = JSON.parse(data)
				var allNum = newData.data - 1
				var currentNum = Number(newData.message)
				if (currentNum < allNum) {
					var chaValue = allNum - currentNum
					$("#div-i-gendanZhuangkuang").html("今日购买：<span class='span-c-tiaoshu'>" + currentNum + "</span>/<span class='span-c-tiaoshu'>" + allNum + "</span>单，还差<span class='span-c-tiaoshu'>" + chaValue + "</span>单<br>还未达到发起跟单的要求，如有疑问，可直接查看跟单玩法说明")
				} else {
					$("#div-i-gendanZhuangkuang").text("已达到发起跟单的要求，可以下注时勾选跟单选项，让其他用户参与跟单。")
				}
				var newRequest = {
					url: "/fqgendan.do",
					type: "post",
					data: {
					},
					success: function(data) {
						var newData = JSON.parse(data)
						insertGenDanItem(data, "#div-i-MyFaQiGenDan", "发起")		
						var newRequest = {
							url: "/cygendan.do",
							type: "post",
							data: {},
							success: function(data) {
								insertGenDanItem(data, "#div-i-MyCanYuGenDan", "参与")	
								$("#myModal").modal("show")
							},
							error: function(status) {
								showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "网络异常，请稍后重试")
							}
						}
						ajax(newRequest)				
					},
					error: function(status) {
						showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "网络异常，请稍后重试")
					}
				}
				ajax(newRequest)				
			},
			error: function(status) {
				showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "网络异常，请稍后重试")
			}
		}
		ajax(newRequest)		
	})
	$("#div-i-myHeMaiBody").on(getEndClickEvent(), ".btn-viewDetailGenDanItem", function(e) {
		var $Parent = $(e.target).closest(".myHeMaiItem")
		$Parent.find(".sub-ul-wanfa").toggleClass("active")
	})
	
	$("#span-i-gendanWanfa").on(getEndClickEvent(), function(e) {
		//showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "<span>目前您还没有参与或发起跟单。</span><br><a style='color:#059BF3;font-weight:bold;font-size:16px;' href='http://www.baidu.com'>点击前往，立刻下注！</a>")
	})
	</script>
</html>